package com.k.demo.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.k.demo.entity.UserAddress;

@Mapper
public interface UserAddressMapper {
	
	@Select("select * from user_addresses where is_delete=1")
	List<UserAddress> seletAll();
	
	@Select("select * from user_addresses where user_id=#{userid} and is_delete=1 order by defult_flag desc")
	List<UserAddress> selectNowAddresses(Integer userid);
	
	//根据用户地址id查找
	@Select("select * from user_addresses where address_id=#{address_id}")
	UserAddress selectAddressById(int address_id);
	
	int insertUserAddress(UserAddress userAddress);
	
	//真删除
	int trueDeleteUserAddresss(Integer address_id);
	
	//假删除
	int falseDeleteUserAddress(Integer address_id);
	
	
	//修改地址
	int modifyUserAddress(UserAddress userAddress);
	
	//个人地址数量统计
	@Select("select count(*) from user_addresses where user_id=#{userid} and is_delete=1")
	int countUserAddress(Integer userid);
	
	//默认地址更新
	@Update("update  user_addresses set defult_flag= 0 where user_id=#{userid}")
	int updateDefult(Integer userid);
	
	
}
